package com.cwd.arm.infrastructure.query;

import com.cwd.arm.common.query.PageQuery;
import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * Created by yan on 21-11-29.
 */
@Data
public class ProjectDaoQuery extends PageQuery {

    private String projectName;

    private String projectType;

    private String businessType;

    private String projectStatus;

    private Integer year;

    private Integer month;

    @Override
    public String getSortColumn() {
        if(StringUtils.isEmpty(sortField)){
            return "create_time";
        }
        if(sortField.equals("projectType")){
            return "project_type_key";
        }
        if(sortField.equals("taxConfirmAmount")){
            return "confirm_amount";
        }
        if(sortField.equals("contractRate")){
            return "`received_amount` / `cal_amount`";
        }
        if(sortField.equals("receivableAmount")){
            return "`confirm_amount` - `received_amount`";
        }
        if(sortField.equals("confirmReceivableDiffAmount")){
            return "`confirm_amount` - `receivable_amount`";
        }
        if(sortField.equals("confirmContractRate")){
            return "`confirm_amount` / `cal_amount`";
        }
        if(sortField.equals("rtRate")){
            return "`confirm_amount` / `cal_amount`";
        }
        if(sortField.equals("workDay")){
            return " `end_date` - `start_date`";
        }
        if(sortField.equals("closeCycle")){
            return "`close_date` - `end_date`";
        }
        if(sortField.equals("taxAmount")){
            return "`received_amount` + `tax_unreceive_amount`";
        }
        return super.getSortColumn();
    }
}
